<%@page import="com.conferences.model.User"%>
<%@page import="com.conferences.model.Conference"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags"%>

	<%
		Conference c = (Conference) request.getAttribute("conference");
		User loggedUser = (User) request.getAttribute("loggedUser");
		List<User> users = c.getUsers();
		
		boolean isAuthor = false;
		if (c.getAuthor().getId().compareTo(loggedUser.getId()) == 0) {
			isAuthor = true;
		}
		
		pageContext.setAttribute("isAuthor", isAuthor);
	    pageContext.setAttribute("users", users);
	%>

<t:template>
	<jsp:attribute name="header">

	    </jsp:attribute>
	<jsp:attribute name="footer">Stopka</jsp:attribute>
	<jsp:body>
	<br/>
	<div class="jumbotron">
	  <div class="container">
	  <div class="page-header">
		  <h1>${conference.subject}</h1>
		  <small>
		  	${conference.author.firstname} ${conference.author.lastname}
		  	<br/>
		  	<fmt:formatDate pattern="dd-MM-YYYY" value="${conference.date}" />
		  	</small>
		  	<br/>
		  	<small>Limit osobowy: ${conference.personLimit}</small>
		</div>
		<p>${conference.content}</p>
	  </div>
	</div>
		<h3>Zapisane osoby:</h3>
			<div class="table-responsive">
		  <table class="table table-hover">
			<thead>
				<tr>
					<th>Imie</th>
					<th>Nazwisko</th>
					<th>E-mail</th>
				</tr>
			</thead>
			<tbody>
			<c:forEach var="user" items="${users}">
				<tr class='userItemRow' id="${user.id}">
					<td>${user.firstname}</td>
					<td>${user.lastname}</td>
					<td>${user.email}</td>
				</tr>
			</c:forEach>
			</tbody>
	      </table>
	    </div>
	<center>
		<c:choose>
			<c:when test="${isAuthor == true}">
				<a href="<c:url value="/conference/remind/${conference.id}.htm" />" class="btn btn-default" role="button">Wyślij przypomnienie</a>
				<a href="<c:url value="/conference/printlist/${conference.id}.htm" />" class="btn btn-default" role="button">Lista do druku</a>
			</c:when>
		</c:choose>
		<a href="<c:url value="/home.htm" />" class="btn btn-default" role="button">Powrót</a>
	</center>
    </jsp:body>
</t:template>